<?php

class Damages_Methods_Request_GetCarDamage extends Damages_Methods_Request {

  /**
   *
   * @var int
   */
  public $id;

  public function __construct($params) {
    parent::__construct($params);
    $this->id = (int) $params->id;
  }

  public function process() {
    $response = new Damages_Methods_Response_GetCarDamage(true);
    $data = $this->getDbObject();
    if ($data)
      $response->setData($data);
    else 
      throw new Damages_Exception_App(Damages_Codes::DB_OBJECT_NOT_FOUND);
    return $response;
  }

  private function getDbObject() {
    $data = DamagesCarDamagesQuery::create()->findOneById($this->id);
    return $data;
  }

}